package DataLayer;
/**
 * @author: Lam Thanh Trung 1101706
 * @purpose: Lop dung de thuc thi cau lenh truy van
 * @Date: 18/9/2013
 */
import java.sql.SQLException;
import java.sql.Statement;
import java.sql.ResultSet;
import java.sql.Connection;

public class ChatQuery {
    private Connection con;
    private Statement st;
    private ResultSet rs;
    
    public ChatQuery() throws SQLException, ClassNotFoundException{
        this.con = ChatConnection.getConnetion();
        this.st = con.createStatement();
    }
    
    public ResultSet getRs(String q) throws SQLException{
        this.rs = this.st.executeQuery(q);
        return this.rs;
    }
    
    public void executeSQL(String q) throws SQLException{
        this.st.execute(q);
    }
    
    public void executeUpdate(String q) throws SQLException{
        this.st.executeUpdate(q);
    }
    
    public void closeCon(){
        ChatConnection.closeConnetion(this.con);
    }
}
